package edu.hm.compiler;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class I18NCompiler
{
    private static final String         BUNDLE_NAME     = "edu.hm.compiler.i18ncompiler";                      //$NON-NLS-1$

    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( I18NCompiler.BUNDLE_NAME );

    private I18NCompiler()
    {}

    public static String getString( final String key )
    {
        try
        {
            return I18NCompiler.RESOURCE_BUNDLE.getString( key );
        } catch( final MissingResourceException e )
        {
            return '!' + key + '!';
        }
    }

    public static String getString( final String key, final Object... args )
    {
        try
        {
            return MessageFormat.format( I18NCompiler.RESOURCE_BUNDLE.getString( key ), args );
        } catch( final MissingResourceException e )
        {
            return '!' + key + '!';
        }
    }
}
